package com.hhs.storage.util;

import com.hhs.storage.bean.Comsumer;
import com.hhs.storage.bean.Region;
import com.hhs.storage.bean.TypeDic;
import com.hhs.storage.service.BaseLogsService;
import org.apache.commons.lang.StringUtils;
import javax.servlet.http.HttpServletRequest;
import java.util.*;

/**
 * @author: HuangHaiShui
 * @description:
 * @date: 2022/9/15 14:54
 * @version: 1.0
 */
public class SysUtil {

    public static final String TOP_DEPART_ID="a3312rraq1";
    //通过nginx直接访问了图片的静态文件夹
    public static final String BASEURL="http://zrtest.tpddns.cn:81/";
//    public static final String BASEURL="http://localhost:8080/";
    public static BaseLogsService logsService;

    //临时合同的类型id-数据库的数据TYPE_DIC表，临时合同要特殊处理
    public static final String TEMP_CONTRACT_TYPEID="8e21951f14c447d091679bf21fbe9dcd";

    //角色flag
    //超级管理员
    public static final String ROLE_FLAG_ADMIN="admin";
    public static final String ROLE_FLAG_HR="hr";
    //调度员
    public static final String ROLE_FLAG_DDY="ddy";
    //下单员
    public static final String ROLE_FLAG_XDY="xdy";
    //业务员
    public static final String ROLE_FLAG_YWY="ywy";
    //经理
    public static final String ROLE_FLAG_JL="jl";
    //总经理
    public static final String ROLE_FLAG_ZJL="zjl";
    //老板
    public static final String ROLE_FLAG_BOSS="boss";
    //车队长
    public static final String ROLE_FLAG_CDZ="cdz";
    //图片上传后，附件的保存的文件夹名称
    public static final String ATTACHMENT_LIST="pptimage";
    //图片上传后，手机管理页面保存的文件夹名称
    public static final String HANDPHONE="handphone";
    //图片上传后，合同的保存的文件夹名称
    public static final String CONTRACT="contract";
    //图片上传后，驾驶证的保存的文件夹名称
    public static final String DRIVER_LICENSE="driverLicense";
    //图片上传后，行驶证的保存的文件夹名称
    public static final String DRIVING_PERMIT="drivingPermit";
    //图片上传后，健康证的保存的文件夹名称
    public static final String HEALTH_CERTIFICATE="healthCertificate";
    //图片上传后，磅单的凭证文件夹名称
    public static final String STACHEL="stachel";
    //图片上传后，产品供应商资质的保存的文件夹名称
    public static final String PRODUCT_SUPPLIER_QUALIFICATION_CERTIFICATE="productSupplierQualificationCertificate";
    //图片上传后，客户资质的保存的文件夹名称
    public static final String COMSUMER_QUALIFICATION_CERTIFICATE="comsumerQualificationCertificate";
    /**
     * 标签类型
     */
    public  final static Map<String,String> TAG_TYPE_MAP=new HashMap<>();
    static {
        TAG_TYPE_MAP.put("personal-title","个人计划-标题");
        TAG_TYPE_MAP.put("personal-content","个人计划-内容");
        TAG_TYPE_MAP.put("project-name","项目计划-标题");

    }
    /**
     * 车辆日志类型
     */
    public  final static Map<Integer,String> CAR_LOG_OPERATION_MAP=new HashMap<>();
    static {
        CAR_LOG_OPERATION_MAP.put(1,"车辆异常");
        CAR_LOG_OPERATION_MAP.put(2,"车辆回收");
        CAR_LOG_OPERATION_MAP.put(23,"车辆切换");
    }
    /**
     * 文件类型
     */
    public  final static Map<Integer,String> COMSUMER_LEVEL_MAP=new HashMap<>();
    static {
        COMSUMER_LEVEL_MAP.put(0,"一般");
        COMSUMER_LEVEL_MAP.put(1,"良好");
        COMSUMER_LEVEL_MAP.put(2,"优秀");

    }
    /**
     * 文件类型
     */
    public  final static Map<String,String> FILE_TYPE_MAP=new HashMap<>();
    static {
        FILE_TYPE_MAP.put("doc","word");
        FILE_TYPE_MAP.put("docx","word");
        FILE_TYPE_MAP.put("ppt","ppt");
        FILE_TYPE_MAP.put("pptx","ppt");
        FILE_TYPE_MAP.put("pdf","pdf");
        FILE_TYPE_MAP.put("xls","excel");
        FILE_TYPE_MAP.put("xlsx","excel");
        FILE_TYPE_MAP.put("jpg","image");
        FILE_TYPE_MAP.put("jpeg","image");
        FILE_TYPE_MAP.put("gif","image");
        FILE_TYPE_MAP.put("png","image");
        FILE_TYPE_MAP.put("svg","image");
        FILE_TYPE_MAP.put("txt","txt");
    }
    /**
     * 目标对象类型
     */
    public  final static Map<Integer,String> TARGET_TYPE_MAP=new HashMap<>();
    static {
        TARGET_TYPE_MAP.put(0,"个人计划");
        TARGET_TYPE_MAP.put(1,"项目计划");
        TARGET_TYPE_MAP.put(2,"职员私信");
        TARGET_TYPE_MAP.put(3,"项目组通知");
        TARGET_TYPE_MAP.put(4,"领导任务");
        TARGET_TYPE_MAP.put(5,"备忘录");
        TARGET_TYPE_MAP.put(6,"档案资料");
        TARGET_TYPE_MAP.put(7,"头像数据");
    }
    /**
     * 车辆状态
     */
    public  final static Map<Integer,String> CAR_STATE_MAP=new HashMap<>();
    static {
        CAR_STATE_MAP.put(0,"空闲");
        CAR_STATE_MAP.put(1,"占用");
        CAR_STATE_MAP.put(2,"异常");
    }
    /**
     * 项目成员类型
     */
    public  final static Map<Integer,String> PROJECT_MEMBER_IDENTITY_TYPE_MAP=new HashMap<>();
    static {
        PROJECT_MEMBER_IDENTITY_TYPE_MAP.put(0,"负责人");
        PROJECT_MEMBER_IDENTITY_TYPE_MAP.put(1,"协助人");
        PROJECT_MEMBER_IDENTITY_TYPE_MAP.put(2,"监督人");
        PROJECT_MEMBER_IDENTITY_TYPE_MAP.put(3,"执行人");
    }
    /**
     * 计划类型
     */
    public  final static Map<Integer,String> PLAN_TYPE_MAP=new HashMap<>();
    static {
        PLAN_TYPE_MAP.put(0,"日常事务");
        PLAN_TYPE_MAP.put(1,"项目事务");
        PLAN_TYPE_MAP.put(2,"空闲");
        PLAN_TYPE_MAP.put(3,"额外事务");
        PLAN_TYPE_MAP.put(4,"请假");
        PLAN_TYPE_MAP.put(5,"业务专属");
    }
    /**
     * 项目工序状态0未完成，1已完成
     */
    public  final static Map<Integer,String> PROJECT_WORKFLOW_STATUS_MAP=new HashMap<>();
    static {
        PROJECT_WORKFLOW_STATUS_MAP.put(0,"未完成");
        PROJECT_WORKFLOW_STATUS_MAP.put(1,"已完成");
    }
    /**
     * 关系类型
     */
    public  final static Map<String,String> RELATE_TYPE_MAP=new HashMap<>();
    static {
        RELATE_TYPE_MAP.put("leader","领导");
        RELATE_TYPE_MAP.put("user","下属");
    }
    /**
     * 计划状态
     */
    public  final static Map<Integer,String> PLAN_STATE_MAP=new HashMap<>();
    static {
        PLAN_STATE_MAP.put(0,"未完成");
        PLAN_STATE_MAP.put(1,"已完成");
    }
    /**
     * 单据类型
     */
    public  final static Map<Integer,String> BUSINESS_DOCUMENT_STATE_MAP=new HashMap<>();
    static {
        BUSINESS_DOCUMENT_STATE_MAP.put(0,"待下单");
        BUSINESS_DOCUMENT_STATE_MAP.put(1,"已下单");
        BUSINESS_DOCUMENT_STATE_MAP.put(2,"已完成");
    }
    /**
     * 单据订单类型
     */
    public  final static Map<Integer,String> BUSINESS_ORDER_STATE_MAP=new HashMap<>();
    static {
        BUSINESS_ORDER_STATE_MAP.put(0,"待完成");
        BUSINESS_ORDER_STATE_MAP.put(1,"完成中");
        BUSINESS_ORDER_STATE_MAP.put(2,"已完成");
    }
    /**
     * 单据派单订单类型
     */
    public  final static Map<Integer,String> BUSINESS_DISPATCH_ORDER_STATE_MAP=new HashMap<>();
    static {
        BUSINESS_DISPATCH_ORDER_STATE_MAP.put(0,"待完成");
        BUSINESS_DISPATCH_ORDER_STATE_MAP.put(1,"已完成");
//        BUSINESS_DISPATCH_ORDER_STATE_MAP.put(2,"已取消");
    }
    /**
     * 单位类型
     */
    public  final static Map<String,String> UNIT_MAP=new HashMap<>();
    static {
        UNIT_MAP.put("tons","吨");
        UNIT_MAP.put("car","车");
    }
    /**
     * 车队类型
     */
    public  final static Map<Integer,String> CAR_FLEET_TYPE_MAP=new HashMap<>();
    static {
        CAR_FLEET_TYPE_MAP.put(0,"自有车队");
        CAR_FLEET_TYPE_MAP.put(1,"外派车队");
        CAR_FLEET_TYPE_MAP.put(2,"客户自提");
    }
    /**
     * 合同类型相关数据
     */
    public static final String KEY_CONTRACT_TYPE="contract_type";//合同类型
    public static  List<TypeDic> CONTRACT_TYPE_LIST=new ArrayList<>();

    public static final String KEY_MODEL_TYPE="type";//合同型号
    public static  List<TypeDic> MODEL_TYPE_LIST=new ArrayList<>();;

    public static final String KEY_PAY_WAY="pay_way";//付款性质
    public static  List<TypeDic> PAY_WAY_LIST=new ArrayList<>();;

    public static final String KEY_PAY_TYPE="pay_type";//付款类型
    public static  List<TypeDic> PAY_TYPE_LIST=new ArrayList<>();
    public static final String KEY_PLAN_YWTYPE="person_plan_ywtype";//个人计划  类型-业务专属
    public static  List<TypeDic> PLAN_YWTYPE_LIST=new ArrayList<>();

    //查询中要被排除的人员，目前就管理员账号要排除
    public static String[] EXCLUDE_USERS={"2"};

    /**
     * 根据id获取业务站点类型数据
     * @param id
     * @return
     */
    public static TypeDic getYWTTypeById(String id){
        for (int i = 0; i <PLAN_YWTYPE_LIST.size() ; i++) {
            TypeDic t=PLAN_YWTYPE_LIST.get(i);
            if (t.getId().equals(id)){
                return  t;
            }
        }
        return null;
    }
    /**
     * 所有客户数据
     */
    public static  List<Comsumer> COMSUMER_LIST;
    //获取当前请求发起人的userId
    //此id在jwt过滤器里赋值的
    public static String getLoginUserId(HttpServletRequest request){
        if(request !=null){
            Map mapParam = request.getParameterMap();
            String[] str = (String[])mapParam.get("lgUserId");
            if(str.length>0 && StringUtils.isNotEmpty(str[0])){
                return str[0];
            }else{
                return null;
            }
        }
        return null;
    }

    public static List<Region>  FJ_REGION;

    //生成uuid
    public static String UUID(){
        return UUID.randomUUID().toString().replaceAll("-","");
    }
    static class Stu{
        int id;
        int age;
        String name;
        public Stu(int id, int age, String name) {
            this.id = id;
            this.age = age;
            this.name = name;
        }

        @Override
        public String toString() {
            return "Stu{" +
                    "id=" + id +
                    ", age=" + age +
                    ", name='" + name + '\'' +
                    '}';
        }
    }
    static class C implements Comparator<Stu>{
        @Override
        //如果返回为0表示两个对象相等
        public int compare(Stu o1, Stu o2) {
            return o1.id-o2.id;
        }
    }
    static class D implements Comparator<Stu>{
        @Override
        //如果返回为0表示两个对象相等
        public int compare(Stu o1, Stu o2) {
            return o2.age-o1.age;
        }
    }
    static class E implements Comparator<Stu>{
        @Override
        //如果返回为0表示两个对象相等
        public int compare(Stu o1, Stu o2) {
            return o1.name.compareTo(o2.name);
        }
    }
    static class F implements Comparator<Stu>{
        @Override
        //如果返回为0表示两个对象相等
        public int compare(Stu o1, Stu o2) {
            if(o1.age-o2.age!=0){
                return o1.age-o2.age;
            }else{
                return o1.name.compareTo(o2.name);
            }
        }
    }
}
